<?php

namespace app\index\controller\lawyer;

use app\index\model\UM as UM;
use app\index\service\LawyerService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * MedalLawyer 控制器
 * Class MedalLawyer
 * @package app\lawyer\controller
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 */
class MedalLawyer
{
    // 请求参数
    private Request $request;
    private LawyerService $service;


    public function __construct(Request $request, LawyerService $lawyerService)
    {
        $this->request = $request;
        $this->service = $lawyerService;
    }

    /**
     * 列表
     * @param \app\index\model\UM|null $user
     * @return ApiResponse
     * @url /lawyer/medal_lawyer/index
     */
    public function index(?UM $user): ApiResponse
    {
        $request = $this->request;

        $cityId = $request->param('cityId');
        $categoryId = $request->param('categoryId');
        $kw = $request->param('kw');
        $order = $request->param('order');
        $page = $request->param('page', 1);
        $page_size = $request->param('page_size', 20);

        return ApiResponse::success($this->service->index($user, $cityId, $categoryId, 1, $kw, $order, $page, $page_size));
    }

}
